<template>
  <view class="uni-wrap">
    <scroll-view class="content">
      <uni-card title="钢瓶信息" :is-shadow="false" :border="false">
        <view class="my-info">
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>钢瓶编码</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.steelcyinderCode }}</text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>钢瓶容量</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.steelcyinderName }}</text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>钢瓶规格</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.steelcyinderSpecs }}</text>
                </view>
              </view>
            </view>
          </view>

          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>阀门型号</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>
                    {{
                    getKeyName(
                    dictDatas.steelcyinder_type,
                    detail.steelcyinderType
                    ) || "-"
                    }}
                  </text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>来源类型</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>
                    {{
                    getKeyName(dictDatas.source_type, detail.sourceType) ||
                    "-"
                    }}
                  </text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>单位</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.steelcyinderUnit || '-' }}</text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>产品名称</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.productName }}</text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>产品规格</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.productSpecs }}</text>
                </view>
              </view>
            </view>
          </view>
          <!-- <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>钢瓶类别</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ getKeyName(dictDatas.bottle, detail.bottle) || "-" }}</text>
                </view>
              </view>
            </view>
          </view>-->
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>总重</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.totalWeight }}</text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>净重</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.netWeight }}</text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>批号</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.batchNumber }}</text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>等级</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.productGrade }}</text>
                </view>
              </view>
            </view>
          </view>

          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>所属车间</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>
                    {{
                    this.getKeyName(
                    dictDatas.workshop,
                    detail.workshopCode
                    ) || "-"
                    }}
                  </text>
                </view>
              </view>
            </view>
          </view>

          <!-- <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>是否出库</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.isUse == 1 ? "是" : "否" }}</text>
                </view>
              </view>
            </view>
          </view>-->

          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>入库时间</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.enableDate || "-" }}</text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>生产日期</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.productDate || "-" }}</text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>有效日期</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.productPeriod || "-" }}</text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item" v-if="isGY">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>二次类别</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.secondType || "-" }}</text>
                </view>
              </view>
            </view>
          </view>
           <view class="my-info-item" v-if="isGY">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>二次总重</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.secondTotalWeight || "-" }}</text>
                </view>
              </view>
            </view>
          </view>
           <view class="my-info-item" v-if="isGY">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>二次净重</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.secondNetWeight || "-" }}</text>
                </view>
              </view>
            </view>
          </view>
          <view class="my-info-item">
            <view class="my-info-item__container">
              <view class="my-info-item__content">
                <view class="my-info-item__content-title">
                  <text>备注</text>
                </view>
              </view>
              <view class="my-info-item__extra">
                <view class="my-info-item__extra-text">
                  <text>{{ detail.remark || "-" }}</text>
                </view>
              </view>
            </view>
          </view>
        </view>
      </uni-card>
    </scroll-view>
  </view>
</template>

<script>
var _self = this;

export default {
  data() {
    return {
      id: "",
      baseUrl: "",
      detail: {},
      imgErrorUrl: "/static/img_error.png",
      dictDatas: {
        source_type: [],
        steelcyinder_type: [],
        bottle: [],
        workshop: [],
        unitList: [
          {
            value: "g",
            label: "g"
          },
          {
            value: "kg",
            label: "kg"
          }
        ]
      }
    };
  },
  onLoad(params) {
    _self = this;
    this.baseUrl = this.$baseUrl; //全局变量baseUrl 单页面要先赋值再使用

    if (params) {
      this.id = params.bottleid;
    }
    this.getDicData("source_type");
    this.getDicData("steelcyinder_type");
    this.getDicData("bottle");
    this.getDicData("workshop");
  },
  onShow() {
    this.getDetail(this.id);
  },
  onReady() {},
  methods: {
    getDetail(id) {
      this.$get(`/basicData/steelcyinder/${id}`, {}).then(res => {
        this.detail = res.data;
      });
    },
    getDicData(dictKey) {
      let that = this;
      this.$get(`/system/dict/data/type/${dictKey}`, {}).then(res => {
        this.dictDatas[dictKey] = res.data;
      });
    },
    getKeyName(dictData, curKey) {
      let result = dictData.find(item => {
        return item.dictValue == curKey;
      });
      return result && result.dictLabel;
    }
  }
};
</script>

<style lang="scss">
.uni-wrap {
  height: auto;
}
</style>
